<%@ page contentType="text/html;charset=UTF-8"  isELIgnored="false" language="java" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/admin.css">
    <script src="../js/jquery-1.4.2.js"></script>
    <script src="../js/jquery.js"></script>
    <script src="../js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 删除学生信息</strong></div>
    <div class="padding border-bottom">
        <%--    输入按钮组--%>
        <div class="form-group" >
            <div style="width: 30px;height: 20px;float: left;"></div><!--用来填充-->
            <div class="label" style="float:left;margin-top: 10px">
                <label>学生学号：</label>
            </div>
            <div class="field" style="float:left;">
                <input type="text" class="input w50" style="width: 200px;" id="id" name="id" placeholder="请输入学生学号..." />
                <div class="tips"></div>
            </div>
            <div style="width: 200px;height: 20px;float: left;"></div><!--用来填充-->
            <div class="label" style="float:left;margin-top: 10px">
                <label>学生姓名：</label>
            </div>
            <div class="field" style="float:left;">
                <input type="text" class="input w50" style="width: 200px;" id="name" name="name" placeholder="请输入学生姓名" />
                <div class="tips"></div>
            </div>
            <div style="width: 200px;height: 20px;float: left;"></div><!--用来填充-->
            <%--      <button style="float:left;" type="button" id="search" class="button border-yellow"><span class="icon-plus-square-o"></span> 查询</button>--%>
            <button style="width: 200px;height: 40px;background-color: #ddeeff" type="button" id="search">查询</button>
            <script>
                $("#search").click(function() {
                    var $tds=$("#table").empty();<!--清空子元素-->
                    $("#table").append("<tr>\n" +
                        "      <th width=\"15%\">学号</th>\n" +
                        "      <th width=\"25%\">姓名</th>\n" +
                        "      <th width=\"15%\">性别</th>\n" +
                        "      <th width=\"20%\">年龄</th>\n" +
                        "      <th width=\"15%\">所在班级</th>\n" +
                        "      <th width=\"10%\">删除该信息</th>\n" +
                        "    </tr>");<!--添加表头-->
                    var id = $("#id").val();
                    if(id==''){
                        id=0;
                    }
                    var name = $("#name").val();
                    $.post(" /search",{id:id,name:name,sex:0,age:18,studentclass:"1882072"},function (data) {
                        if(data.length==0){
                            $("#table").append("<tr><td colspan='5' align='center'>空</td></tr>");
                        }
                        for(j = 0; j < data.length; j++) {
                            var t="<tr><td>"+data[j].id+"</td><td>"+data[j].name+"</td><td>"+data[j].sex;
                            t+="</td><td>"+data[j].age+"</td><td>"+data[j].studentclass;
                            t+="<td><a href='javascript:deleteStudent("+data[j].id+")'>删除</a></td></tr>";
                            $("#table").append(t);
                        }
                    },"json");
                });
                function deleteStudent(id) {
                    if(confirm("你确定要删除这条消息？")) {
                        $.post("/delete", {id: id}, function (data) {
                            alert(data);
                            $("#search").click();
                        }, "json");
                    }
                }
            </script>
        </div>
    </div>
    <table class="table table-hover text-center" id="table">
        <tr>
            <th width="15%">学号</th>
            <th width="25%">姓名</th>
            <th width="15%">性别</th>
            <th width="20%">年龄</th>
            <th width="15%">所在班级</th>
            <th width="10%">删除该信息</th>
        </tr>
    </table>
</div>
</div>
</body></html>
